home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / Old Scripts / LineLink Fax2&ARA < prev    next >
Text File  |  1994-02-01  |  6KB  |  265 lines

  1. ! Version 2.1
  2. !
  3. !$ Requires: ProModem 144e LineLink modem.
  4.  
  5. !$ Supports: fax and ARA software in the server mode.
  6.  
  7. !$ Use:   Class 2 for Fax, ARA/LineShare for ARA.
  8.  
  9.  
  10. ^2 Speaker On:          = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  11. ^3 Speaker Volume:         = Enum("Low"="1","Medium"="2","High"="3") "2"
  12. ^4 Answer On:           = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  13. ^5 Fax Identifier:      = Text "Stalker_GmbH"
  14. ^6 Additional Cmds:  = Text ""
  15. ! ------------------------------------------
  16. ! Resetting the modem:
  17. ! ------------------------------------------
  18. @Hangup
  19.   SetTries 2
  20.   Flush
  21.   HsReset 0,0,17,19,0,0
  22.   SetSpeed 19200
  23. !
  24. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  25. ! to enter the command mode
  26. !
  27. @Label 1
  28.   matchclr
  29.   matchstr 1 2 "OK\r\n"
  30.   write "ATH0&F\r"
  31.   matchread 20
  32.   ChrDelay 1
  33.   Write "+++"
  34.   ChrDelay 0
  35.   Pause 7
  36.   DtrClear
  37.   SBreak
  38.   DtrSet
  39. !
  40.   DecTries
  41.   IfTries 0 1
  42. !
  43. ! OSErr -6019 "Modem error - the modem is not responding"
  44. !
  45.   exit -6019
  46. @Label 2
  47.   write "ATZ\r"
  48.   Jsr 100
  49. ! write "AT&F+FCLASS=0;+FAA=0\r"
  50.   write "AT&F\r"
  51.   Jsr 100
  52.   exit 0
  53.  
  54. ! ------------------------------------------
  55. !    Receiving incoming calls
  56. ! ------------------------------------------
  57. @ANSWER
  58. @Label 10
  59. !
  60. ! Set the modem preferred speed first
  61. !
  62.   SerReset 19200,0,8,1
  63.   Jsr 80
  64. !
  65. ! Set the common options
  66.   Jsr 70
  67. !
  68. ! Set the communication options:
  69. ! • Normal connection (for ARA), report DCE speed
  70. ! • HW flow control   (for ARA, Fax should not use a handshake on receiving)
  71.   Write "AT \\N0 W2 &K3 ^6\r"
  72.   Jsr 100
  73. !
  74. ! Set Fax parameters: LID, DCC,BOR
  75. !
  76.   Write "AT+FCLASS=2\r"
  77.   Jsr 100
  78.   Write "AT+FLID=\"^5\"\r"
  79.   Jsr 100
  80.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  81.   Jsr 100
  82.   Write "AT+FBOR=1\r"
  83.   Jsr 100
  84.   Write "AT+FCR=1\r"
  85.   Jsr 100
  86. !
  87. ! Tell the modem to determine the type of the incoming call
  88. ! Fetch the tube after ^4 rings
  89. !
  90.   Write "ATS0=^4+FAA=1\r"
  91.   Jsr 100
  92. !
  93. ! Everything is ready - let's sit and wait for a call
  94. ! We'll wait for 2 minutes, then reinitiate the modem
  95. !
  96.   Note "Waiting for a fax or ARA call…"
  97. @Label 15
  98.   MatchClr
  99.   matchstr 1 16 "RING\r\n"
  100.   matchstr 2 20 "\r\nCARRIER "
  101.   matchstr 3 20 "\r\nCONNECT "
  102.   matchstr 5 30 "\r\n+FCON"
  103.   matchstr 6 10 "\r\nNO "
  104.   matchstr 7 10 "\r\nBUSY"
  105.   Matchread 1200
  106.   jump 10
  107. @Label 16
  108.   Note "Ring…"
  109.   jump 15
  110. !
  111. ! Data connection has been established (we read "CARRIER" or "CONNECT ")
  112. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  113. ! if it was an incoming call, put the "RING" before the "CONNECT"
  114. !
  115. @Label 20
  116.   QueueInput "\r\nCARRIER "
  117.   ifOriginate 21
  118.   QueueInput "\r\nRING\r\n"
  119. @Label 21
  120.   Attach "ARA" (DTR,Escape)
  121. !
  122. ! Fax connection has been established (we read "+FCON")
  123. ! Put the +FCON back to the buffer,
  124. ! if it was an incoming call, put the "RING" before the "+FCON"
  125. ! Attach the "Fax" subPort
  126. !
  127. @Label 30
  128.   QueueInput "\r\n+FCON"
  129.   ifOriginate 31
  130.   QueueInput "\r\nRING\r\n"
  131. @Label 31
  132.   Attach "Fax" (DTR,Reset,Escape,IdleLimit=30)
  133.  
  134. @Label 50
  135.   Note "Suspended"
  136.   Say "Press the Options… button to enter the AT-strings for your modem!"
  137.   Pause 1200
  138.   Jump 50
  139. ! ------------------------------------------
  140. ! Originating a call through the "ARA" subport
  141. ! ------------------------------------------
  142. @ORIGINATE "ARA"
  143.   SerReset 19200,0,8,1
  144.   Jsr 80
  145. !
  146. ! Set the common options
  147. !
  148.   Jsr 70
  149. !
  150. ! Set the Data mode:
  151. ! • Normal connection (no compression, correction - for ARA), report DCE rate
  152. ! • HW Handshake
  153. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  154. !
  155.   Write "AT\\N0 W2 \\Q3 S7=90 ^6\r"
  156.   Jsr 100
  157. !
  158. ! Prepare to receive all error result codes, dial the number
  159. !
  160.   Jsr 90
  161.   MatchStr 1 20 "\r\nCARRIER "
  162.   MatchStr 2 20 "\r\nCONNECT "
  163.   MatchRead 1000
  164.   Write "\r"
  165.   Exit -6019
  166.  
  167. ! ------------------------------------------
  168. ! Originating a call through the "Fax" subPort
  169. ! ------------------------------------------
  170. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  171. !
  172. ! Set the "Fax" speed
  173. !
  174.   SerReset 19200,0,8,1
  175.   Jsr 80
  176. !
  177. ! Set the common options
  178. !
  179.   Jsr 70
  180. !
  181. ! Set the Fax mode
  182. ! • Xon/Xoff handshake
  183. !
  184.   Write "AT\\Q1+FCLASS=2\r"
  185.   Jsr 100
  186. !
  187. ! Now emit all commands that the application has sent to that port,
  188. !
  189.   Jsr 60
  190. !
  191. ! Prepare to receive all error result codes, dial the number
  192. !
  193.   Jsr 90
  194.   MatchStr 1 30 "\r\n+FCON"
  195.   MatchRead 1000
  196.   Write "\r"
  197.   Exit -6019
  198. !
  199. ! This section emits all modem commands sent from the client application
  200. ! For each set of commands the "OK" answer is awaited
  201. !
  202. @Label 60
  203.   EmitStart
  204. @Label 61
  205.   EmitCommand 62
  206.   Jsr 100
  207.   Jump 61
  208. @Label 62
  209.   return
  210. !
  211. ! This section initiates the modem before ANSWER and ORIGINATEs:
  212. ! extended responses + speaker control +
  213. ! command mode on Dtr drop + DCD valid
  214. ! Verbal responses mode, no echo 
  215. !
  216. @Label 70
  217.   Write "ATM^2L^3&D2V1E0\r"
  218.   Jump 100
  219.  
  220. !
  221. ! This section syncronize the modem after the serial port speed switching
  222. !
  223. @Label 80
  224.   ChrDelay 1
  225.   Write "AT\r"
  226.   ChrDelay 0
  227.   Jump 100
  228.  
  229. !
  230. ! Prepare to receive error result codes, send the dialing command and
  231. ! set the user's handshake mode
  232. !
  233. @Label 90
  234.   MatchClr
  235.   MatchStr 2 91 "NO DIALTONE\r\n"
  236.   MatchStr 3 92 "BUSY\r\n"
  237.   MatchStr 4 93 "NO CARRIER\r\n"
  238.   MatchStr 5 94 "NO ANSWER\r\n"
  239.   Write "ATD^1\r"
  240.   HsReset *
  241.   return
  242. @Label 91
  243.   exit -6020
  244. @Label 92
  245.   exit -6022
  246. @Label 93
  247.   exit -6021
  248. @Label 94
  249.   exit -6023
  250. !
  251. ! Processing the AT command:
  252. ! OK -> proceed
  253. ! ERROR or TimeOut ->exit -6019
  254. ! It can be called AFTER the "Write" command, since LineShare buffers input
  255. !
  256. @Label 100
  257.   MatchClr
  258.   MatchStr 1 102 "\r\nOK\r\n"
  259.   MatchStr 2 101 "\r\nERROR\r\n"
  260.   MatchRead 20
  261. @Label 101
  262.   Exit -6019
  263. @Label 102
  264.   return
  265.